<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Services\MatchService;
use Illuminate\Http\Request;

class MatchController extends Controller
{
    private $matchService;
    public function __construct(MatchService $matchService)
    {
        $this->matchService = $matchService;
    }
    public function matchList(Request $request)
    {
        $params = $request->input();
        $result = $this->matchService->matchList($params);
        return $this->responseSuccess($result);
    }


    public function matchAdd(Request $request)
    {
        $params = $request->input();
        if (!isset($params['maker_id']) && empty($params['maker_id'])){
            $params['maker_id'] = $this->getUid();
        }
        $result = $this->matchService->matchAdd($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError("更新失败，请重试！");

    }

    public function matchDel(Request $request)
    {
        $params = $request->input();
        $result = $this->matchService->matchDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

}
